package com.example.usage.ioc;

import com.example.usage.ioc.bean.student.Student;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * @author jiangzhe
 * @create 2021/9/2 14:09
 *
 * 两种方式： @Configuration+@Bean->(student) 或 @Component+@ComponentScan->(car)
 */
// @Configuration 注解用来说明这是一个配置文件，SpringBoot 会根据这个注解生成IOC容器，以便装配 Bean。
@Configuration
@ComponentScan(value = "com.example.usage.ioc.bean.car")
public class MySpringBootConfig {

    // @Bean 注解用来装配Bean,在注解下方生成的Bean会被装配到IOC容器
    @Bean(name = "student")
    public Student getStu(){
        return new Student(1L,"jz",27);
    }
}
